from typing import List


class Solution:
    def checkXMatrix(self, grid: List[List[int]]) -> bool:
        rank = len(grid)
        for i in range(rank):
            for k in range(rank):
                if i == k or i+k == rank-1:
                    if grid[i][k] == 0:
                        return False
                elif grid[i][k] != 0:
                    return False

        return True


print(Solution().checkXMatrix(
    [[5,7,0],[0,3,1],[0,5,0]]))
